//可以正常运行，但我还是再试试单例模式
// export class  globalThis {
//   static a: number = 0;
//   static b: string = "";
//   static progressMsg:string="";
// }
//
// // 使用示例
// globalThis.a = 3;
// globalThis.b = "aaa";

//下面是单例模式的GlobalState
/**
 * 该类的作用，专门通过单例模式来实现全局变量的一个使用,代替了以前的globalThis
 */
class GlobalState {
  private static _instance: GlobalState;

  public a: number = 0;
  public b: string = "";
  public progressMsg:string="";

  private constructor() {}

  public static getInstance(): GlobalState {
    if (!GlobalState._instance) {
      GlobalState._instance = new GlobalState();
    }
    return GlobalState._instance;
  }

  // Getter 和 Setter 方法
  public getProgressMsg(){
    return this.progressMsg;
  }
  public setProgressMsg(progressMsg:string){
    this.progressMsg=progressMsg;
  }
}
export  const globalState = GlobalState.getInstance();